package de.koller.aframe.util.filter;

import de.koller.oceanFramework.gl.util.RasterManager;
import de.koller.oceanFramework.util.ColorIntUtil;

public class Combine {

	private Combine() {}
	
	public static void max( RasterManager m1, RasterManager m2, RasterManager out ) {
		for( int x = 0; x < out.getWidth(); x++ )
			for( int y = 0; y < out.getHeight(); y++ ) {
				int a = Math.max(	ColorIntUtil.getAValue( m1.colorAt( x, y ) ), 
									ColorIntUtil.getAValue( m2.colorAt( x, y ) ) );
				int r = Math.max(	ColorIntUtil.getRValue( m1.colorAt( x, y ) ), 
									ColorIntUtil.getRValue( m2.colorAt( x, y ) ) );
				int g = Math.max(	ColorIntUtil.getGValue( m1.colorAt( x, y ) ), 
									ColorIntUtil.getGValue( m2.colorAt( x, y ) ) );
				int b = Math.max(	ColorIntUtil.getBValue( m1.colorAt( x, y ) ), 
									ColorIntUtil.getBValue( m2.colorAt( x, y ) ) );
				out.setPixel( ColorIntUtil.getIntColor( a, r, g, b ), x, y );
			}
	}
	
	public static void add( RasterManager m1, RasterManager m2, RasterManager out ) {
		for( int x = 0; x < out.getWidth(); x++ )
			for( int y = 0; y < out.getHeight(); y++ ) {
				out.setPixel( ColorIntUtil.add( m1.colorAt( x, y ), m2.colorAt( x, y ) ), x, y );
			}
	}
}
